ig.module('plugins.text').requires('impact.system').defines(function(){
    "use strict";
    
    /* 
     Text
     ------Create------
     var text = new ig.Text('this is a text.');
     var text = new ig.Text('this is a text.','#ffffff');
     var text = new ig.Text('this is a text.','#ffffff','1.5em Verdana','center');
     ------Use------
     draw:function(){
     this.text.draw(100,100);
     }
     draw:function(){
     this.parent();
     this.text.draw(100,100,300);//max width 300
     }
     */
    ig.Text = ig.Class.extend({
        text: undefined,
        color: 'black',
        font: '1em Verdana',
        baseLine: 'top',
        align: 'left',
        init: function(text, color, font, align){
            this.text = text || '';
            this.color= color || this.color;
            this.font = font || this.font;
            this.align= align || this.align;
        },
        draw: function(x, y, maxWidth){
			if (!this.text) {
				return;
			}
			
            ig.system.context.fillStyle = this.color;
            ig.system.context.font = this.font;
            ig.system.context.textAlign = this.align;
            ig.system.context.textBaseline = this.baseLine;
            if (maxWidth)
                ig.system.context.fillText(this.text, ig.system.getDrawPos(x), ig.system.getDrawPos(y), maxWidth);
            else 
                ig.system.context.fillText(this.text, ig.system.getDrawPos(x), ig.system.getDrawPos(y));
        }
    });
});
